package com.laboratory.report.lab02.lab0205;

/**
 * 驾驶员
 */
public class Driver {

    private int age;
    private String type;

    public Driver(int age, String type) {
        this.age = age;
        this.type = type;
    }

    public void drive(Vehicle v) {
        if("A1".equals(type) && (age<26 || age>50)) {
            throw new IllegalAgeException();
        }
        if("A2".equals(type) && (age<27 || age>49)) {
            throw new IllegalAgeException();
        }
        if("A3".equals(type) && (age<28 || age>48)) {
            throw new IllegalAgeException();
        }
    }
}
